package com.service.business.support;

import com.google.common.collect.Maps;
import com.service.business.base.service.ConfigService;
import com.service.business.message.MessageSender;
import com.service.business.utils.HttpUtil;
import com.service.dao.constants.ConfigConstants;
import com.service.dao.model.SysConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * <dl>
 * <dt>platform</dt>
 * <dd>Description:</dd>
 * <dd>Copyright: Copyright (C) 2015</dd>
 * <dd>Company: </dd>
 * <dd>CreateDate: 2019年04月21日</dd>
 * </dl>
 *
 * @author
 */
@Component
public class WxMsgUtil {

    @Autowired
    private ConfigService configService;

    @Autowired
    private MessageSender messageSender;

    private static String KEY = "SCU86814T0c58ab24edbe741468e5fb0d2e0e66ab5e58a268212b3";

    private static String url = "https://sc.ftqq.com/" + KEY + ".send";

    public void sendFTWxMsg(String text, String desp) {
        Map<String, SysConfig> configMap = configService.getConfigMapByGroup(ConfigConstants.Group.admin.getCode());

        String mobile = configMap.get(ConfigConstants.ADMIN_RECEIVE_MSG_MOBILE).getConfValue();
        String phoneCode = configMap.get(ConfigConstants.ADMIN_RECEIVE_MSG_PHONE_CODE).getConfValue();

        String msg = "【" + text + "】" + desp;
        messageSender.send(mobile, phoneCode, msg, null);
    }

}
